<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fnx" uri="http://java.sun.com/jsp/jstl/functionsx" %>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="f" uri="http://www.sctv.com/tags/form" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<!DOCTYPE html>
<html>
<head>
    <jsp:include page="/WEB-INF/views/head.jsp"/>
    <script>
        $(function () {
            $("#sortHead").headSort();

            <%--<shiro:hasPermission name="ext:push:view">--%>
            <%--$("#pagedTable tbody tr").dblclick(function (eventObj) {--%>
            <%--var nodeName = eventObj.target.nodeName.toLowerCase();--%>
            <%--if (nodeName != "input" && nodeName != "select" && nodeName != "textarea") {--%>
            <%--location.href = $("#view_opt_" + $(this).attr("beanid")).attr('href');--%>
            <%--}--%>
            <%--});--%>
            <%--</shiro:hasPermission>--%>
        });

        function confirmDelete() {
            return confirm("<s:message code='confirmDelete'/>");
        }

        function optSingle(opt) {
            if (Cms.checkeds("ids") == 0) {
                alert("<s:message code='pleaseSelectRecord'/>");
                return false;
            }
            if (Cms.checkeds("ids") > 1) {
                alert("<s:message code='pleaseSelectOne'/>");
                return false;
            }
            var id = $("input[name='ids']:checkbox:checked").val();
            location.href = $(opt + id).attr("href");
        }

        function optMulti(form, action, msg) {
            if (Cms.checkeds("ids") == 0) {
                alert("<s:message code='pleaseSelectRecord'/>");
                return false;
            }
            if (msg && !confirm(msg)) {
                return false;
            }
            form.action = action;
            form.submit();
            return true;
        }

        //set启动和关闭 广告
        function startEndPage(ids, value) {
            var modifyTime = $('#setDateTime').val();
            /*   startEnd  */
            var data = {};
            data.ids = ids;
            data.isStart = value;
            data.modifyTime = modifyTime;
            var obj = ajaxView("/cmscp/ext/start_page/startEnd.do", "json", data);
            confirm(obj.msg);
        }


        function ajaxView(mothe, datatype, data) {
            var obj;
            var strurl = window.location.host;
            $.ajax({
                type: "POST",
                url: "http://" + strurl + mothe,
                dataType: datatype,
                data: data,
                async: false,
                success: function (msg) {
                    obj = msg;
                },
                error: function (msg) {
                }
            });
            return obj;
        }

        function optDelete(form) {
            if (Cms.checkeds("ids") == 0) {
                alert("<s:message code='pleaseSelectRecord'/>");
                return false;
            }
            if (!confirmDelete()) {
                return false;
            }
            form.action = 'delete.do';
            form.submit();
            return true;
        }

        //生成启动页
        function generationAppversion() {
            location.href = '/cmscp/core/generation/generationAppversion.do';
        }
    </script>
</head>
<body class="skin-blue content-body">
<jsp:include page="/WEB-INF/views/commons/show_message.jsp"/>
<div class="content-header">
    <h1>（Android）版本更新信息 - <s:message code="list"/>
        <small>(<s:message code="totalElements" arguments="${pagedList.totalElements}"/>)</small>
    </h1>
</div>
<div class="content">
    <div class="box box-primary">
        <div class="box-body table-responsive">
            <form action="list.do" method="get" class="form-inline ls-search">
                <div class="form-group">
                    <label for="search_CONTAIN_description">更新描述</label>
                    <input class="form-control input-sm" type="text" id="search_CONTAIN_description"
                           name="search_CONTAIN_description"
                           value="${search_CONTAIN_description[0]}"/>
                </div>
                <button class="btn btn-default btn-sm" type="submit"><s:message code="search"/></button>
            </form>
            <form method="post">

                <div class="btn-toolbar ls-btn-bar">
                    <div class="btn-group">
                        <shiro:hasPermission name="ext:appversion:create">
                            <button class="btn btn-default" type="button"
                                    onclick="location.href='create.do?${searchstring}';">
                                <s:message code="create"/></button>
                        </shiro:hasPermission>
                    </div>
                    <div class="btn-group">
                        <shiro:hasPermission name="ext:appversion:delete">
                            <button class="btn btn-default" type="button" onclick="return optDelete(this.form);">
                                <s:message code="delete"/></button>
                        </shiro:hasPermission>
                    </div>
                    <div class="btn-group">
                        <shiro:hasPermission name="core:appversion:generationAppversion">
                            <a class="btn btn-primary" style="margin-left: 10px;" href="javascript:void(0);"
                               onclick="generationAppversion()"><s:message code="generate"/></a>
                        </shiro:hasPermission>
                    </div>
                </div>

                <table id="pagedTable" class="table table-condensed table-bordered table-hover ls-tb">
                    <thead id="sortHead" pagesort="<c:out value='${page_sort[0]}' />" pagedir="${page_sort_dir[0]}"
                           pageurl="list.do?page_sort={0}&page_sort_dir={1}&${searchstringnosort}">
                    <tr>
                        <th width="25"><input type="checkbox" onclick="Cms.check('ids',this.checked);"/></th>
                        <th width="30" class="ls-th-sort"><span class="ls-sort" pagesort="id">ID</span></th>
                        <th>下载地址</th>
                        <th>更新描述</th>
                        <th>是否强制更新</th>
                        <th>版本序号</th>
                        <th>版本号</th>
                        <th>是否发布</th>
                        <th>创建人</th>
                        <th class="ls-th-sort"><span class="ls-sort" pagesort="createDate">创建时间</span></th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <%------------------------------[ 循环 ]-------------------------------%>
                    <tbody>
                    <c:forEach var="bean" varStatus="status" items="${pagedList.content}">
                        <tr beanid="${bean.id}">
                            <td align="center"><input type="checkbox" name="ids" value="${bean.id}"/></td>
                            <td align="center"><c:out value="${bean.id}"/></td>
                            <td><c:out value="${bean.address}"/></td>
                            <td><c:out value="${bean.description}"/></td>
                            <td><c:if test="${bean.force}">是</c:if><c:if test="${!bean.force}">否</c:if></td>
                            <td><c:out value="${bean.versionCode}"/></td>
                            <td><c:out value="${bean.versionName}"/></td>
                            <td><c:if test="${bean.publish eq '1'}"><span style="color: red">是</span></c:if><c:if
                                    test="${bean.publish eq '2'}">否</c:if></td>
                            <td align="center"><c:out value="${bean.user.username}"/></td>
                            <td align="center">
                                <fmt:formatDate value="${bean.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
                            </td>
                            <td align="center">
                                    <shiro:hasPermission name="ext:appversion:edit">
                                <a href="edit.do?id=${bean.id}&position=${pagedList.number*pagedList.size+status.index}"
                                   class="ls-opt">修改</a>
                                    </shiro:hasPermission>

                                    <shiro:hasPermission name="ext:appversion:delete">
                                <a href="delete.do?ids=${bean.id}" onclick="return confirmDelete();" class="ls-opt">删除</a>
                                    </shiro:hasPermission>
                            </td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
                <c:if test="${fn:length(pagedList.content) le 0}">
                    <div class="ls-norecord"><s:message code="recordNotFound"/></div>
                </c:if>
            </form>
            <form action="list.do" method="get" class="ls-page">
                <tags:search_params excludePage="true"/>
                <tags:pagination pagedList="${pagedList}"/>
            </form>
        </div>
    </div>
</div>
</body>
</html>